#! /usr/bin/env python3

from isa_spec import isa_lists
from isa_spec import get_functions_in_class
import argparse
import os
#import logging

parser = argparse.ArgumentParser(description='XINYUN Verification FLow')
parser.add_argument("-c", "--clean", action="store_true", default=False, dest='Clean', \
                         help="clean the dir")
args=parser.parse_args()

class ISA:
# the generate for GPGPU 
    def __init__(self):
        self.isa_objs = {}
        for name in isa_lists.keys():
            self.isa_objs[name] = get_functions_in_class(isa_lists[name])

    def generate(self):
        for i in self.isa_objs.keys():
            obj = self.isa_objs[i]
            #obj.setLog(self.logger)
            for j in obj.opcodes:
                method = getattr(obj, j)
                method()
            obj.getFile()

if __name__ == "__main__":
    if args.Clean:
        for i in isa_lists.keys():
          name = "%s_instructions.xml"%(i.lower())
    else:
        isa = ISA()
        isa.generate()